<?php

class Jf_Controller_Plugin_Timer extends Jf_Controller_Plugin_Abstract {

    public function routeStartup (Jf_Controller_Request_Abstract $request, Jf_Controller_Response_Abstract $response) {
        Jf_Utility_Timer::setRequestTime ();
    }

    public function dispatchLoopShutdown (Jf_Controller_Request_Abstract $request, Jf_Controller_Response_Abstract $response) {
        $time = Jf_Utility_Timer::timeSinceStartOfRequest ();
        $config = Jf_Application::app () -> getConfig ();
        $config_time = isset ($config['log_slow_time']) ? $config['log_slow_time'] : 0.5;
        if ($time > $config_time) {
            Jf::log ("process time is ($time)  to slow", Zend_Log::WARN, 'slow.log');
        }
    }

}
